import { request } from '@/common/request'

interface ListCommonParams {
    pageSize?: number;
    pageNum?: number;
    page?: number;
}
const api = {
	workshopAutoLogin:(code:string)=>{
		return request({
			url:'/jsWxUser/workWechatUserInfo?code='+code,
			method:'post'
		})
	},
	login: (data : { code : string }) => {
		return request({
			data:{...data,type:'head'},
			url: '/jsWxUser/login?type=head&code='+data.code,
			method: 'post',
		})
	},
	userBindPhone: (data : any) => {
		return request({
			data:{...data,type:'head'},
			url: '/jsWxUser/userBindPhone',
			method: 'get',
		})
	},
	setUserInfo:(data : any,header?:any) => {
		return request({
			data,
			url: '/jsWxUser/updatePersonalDetails',
			method: 'put',
		},header)
	},
	getUserInfo: () => {
		return request({
			url: '/jaWxUser/userBindPhone',
			method: 'get',
		})
	},
	recommendDoctorInfo: () => {
		return request({
			url: '/jsDoctor/applet/recommendDoctorInfo',
			method: 'get',
		})
	},
	recommendGoodsInfo: () => {
		return request({
			url: '/jsGoods/applet/recommendGoodsInfo',
			method: 'get',
		})
	},
	/**
	* @description 查询医生信息
	* @param stairOfficesDirector [string] 所属一级科室
	* @param twoOfficesDirector [string] 所属二级科室
	* @param adeptIllness [string] 擅长疾病
	* @param placeStoreId [string] 所属医馆id 
	**/
	getDoctorInfo:(params:{stairOfficesDirector?:string,twoOfficesDirector?:string,adeptIllness?:string,placeStoreId?:string}) => {
		return request({
			data:params,
			url:"/jsDoctor/applet/findDoctor",
			method: 'get',
		})
	},
	/**
	* @description 查询基础信息树形结构 
	* @param type [string] 类型(KS 科室,JB 疾病)
	**/
	getBaseInfo:(type:string) => {
		return request({
			data:{type},
			url:'/jsBasicsInfo/applet/findBasicsInfoTree',
			method: 'get',
		})
	},
	/**
	* @description 查询筛选的医馆信息 
	**/
	getScreenClinic:() => {
		return request({
			url:'/jsHome/findScreenClinic',
			method: 'get',
		})
	},
	/**
	* @description 根据分类查询医馆信息
	* @param id = [string] 医馆id
	* @param type = [string] 机构类型
	* @param keyword = [string] 关键词
	* @param latitude = [number] 用户纬度
	* @param longitude = [number] 用户经度
	* @param distanceSort = [string] 距离排序方式(ASC:距离由近到远, DESC:距离由远到近)
	* @param scaleSort = [string] 规模排序方式(ASC:规模由小到大, DESC:规模由大到小)
	**/
	getClinicInfoByType:(data:any & ListCommonParams)=>{
		return request({
			data:data,
			url:"/jsHome/findClinicInfoByType",
			method: 'post',
		})
	},
	/**
	 * @description 提交预约信息
	 * @param userId 用户ID
	 * @param placeStoreId 医馆ID
	 * @param appointmentDate 预约日期（yyyy-MM-dd）
	 * @param appointmentTime 预约时间段（如：9:00~12:00）
	 * @param patientName 预约人姓名
	 * @param patientGender 预约人性别（1=男，0=女）
	 * @param contactPhone 联系电话
	 * @returns Promise<any> 预约提交结果，成功时code=200
	 */
	submitAppointment: (data: {
	  userId: string,
	  placeStoreId: string,
	  appointmentDate: string,
	  appointmentTime: string,
	  patientName: string,
	  patientGender: string,
	  contactPhone: string
	}) => {
	  return request({
	    url: '/appointment/submit',
	    method: 'post',
	    data
	  })
	},
	/**
	* @description  AI对话
	* @param message:string 内容
	* @param ifNetworking:string 是否联网 -默认：否
	**/
	AIVoiceChat:(message:string,ifNetworking:string = '否')=>{
		return request({
			url:`/chat/testChat?message=${message}&ifNetworking=${ifNetworking}`,
			method: 'get',
		})
	},
	/**
	* @description 咨询医生支付 
	* @param storeId = [string] 医馆id
	* @param doctorId = [string] 医生id
	* @param paymentPrice = [number] 支付金额(分)  
	**/
	paymentRequest:(data:{storeId:string,doctorId:string,paymentPrice:number})=>{
		return request({
			data,
			url:'/wxPay/consultPay',
			method:"post"
		})
	}
}
export default api